<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <script src="__STATIC__/js/jquery.js"></script>
    <script src="__STATIC__/layui/layui.js"></script>
    <script type="text/javascript" src="__STATIC__/x-admin/js/xadmin.js"></script>
    <link rel="stylesheet" href="__STATIC__/x-admin/css/font.css">
    <link rel="stylesheet" href="__STATIC__/x-admin/css/xadmin.css">
    <link rel="stylesheet" href="__STATIC__/layui/css/layui.css">
</head>
<body>
<form class="layui-form" action="" onsubmit="return false" style="padding-top: 5px;width: 500px" id="reply">
    <input type="hidden" value="{$data.id}" name="id">
    <div class="layui-form-item layui-form-text">
        <label class="layui-form-label">回复</label>
        <div class="layui-input-block">
            <textarea name="contents" placeholder="请输入内容" class="layui-textarea" lay-verify="contents"></textarea>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="sub">立即回复</button>
        </div>
    </div>
</form>
<script>
    layui.use(['form', 'layedit', 'laydate'],function () {
        var form = layui.form;
        form.verify({
            contents: function(value){
                if(value.length < 4){
                    return '内容请输入至少4个字符';
                }
            }
        });
        form.on('submit(sub)', function(data) {
            $.ajax({
                type:'POST',
                url:'/feedback/reply',
                data:$("#reply").serialize(),
                success:function(res){
                    if(res.code){
                        layer.msg(res.msg,{icon:1,time:2000},function () {
                            var index = parent.layer.getFrameIndex(window.name);
                            parent.layer.close(index);
                        });
                    }else{
                        layer.msg(res.msg,{icon:5,time:2000});
                    }
                }
            });
        });
    })
</script>
</body>
</html>